﻿#region License
// <copyright file="IRepository.cs" company="Kopigi - Marc Plessis">
// Copyright © Kopigi 2011
// </copyright>
// ****************************************************************************
// <author>Marc Plessis</author>
// <email>marc.plessis@kopigi.fr</email>
// <date>03/04/2011</date>
// <project>Biwo</project>
// <web>http://www.kopigi.fr/biwo</web>
// <license>
// See license.txt in this solution or http://www.microsoft.com/opensource/licenses.mspx
// </license>
#endregion

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Objects;
using System.Linq;
using System.Linq.Expressions;

namespace $rootnamespace$
{
    public interface IRepository<T> : IDisposable where T : class
    {
        void Add(T entity, object prefixPrimaryKey);
        void Attach(T entity);
        void Delete(T entity);
        void Delete(Expression<Func<T, bool>> predicate);
        void DeleteAll();
        IQueryable<T> Fetch();
        T First(Expression<Func<T, bool>> predicate);
        IQueryable<T> GetAll();
        T GetById(object id, bool includeAddedEntities = false);
        EntityState GetEntityState(T entity);
        IEnumerable<ObjectStateEntry> GetObjectStateEntry(EntityState stateFilter);
        bool IsNew(T entity);
        T Save(T entity, object prefixPrimaryKey);
        int SaveChanges();
        T Single(Expression<Func<T, bool>> predicate);
        IQueryable<T> Where(Expression<Func<T, bool>> predicate);
    }
}
